﻿/**
 * @file   FITKNastranAbstractAdaptor.h
 * @brief  抽象的Nastran文件读写适配器
 * @author zhourp (zhourunping@diso.cn)
 * @date   2024-03-15
 */
#ifndef FITKNASTRANABSTRACTADAPTOR_H
#define FITKNASTRANABSTRACTADAPTOR_H

#include "FITKNastranBDFIOAPI.h"
#include "FITKNastranBDFReader.h"
#include "InpNastranReaderHelper.h"
#include "FITKNastranBDFWriter.h"
#include "InpNastranWriterHelper.h"

#include "FITK_Kernel/FITKAdaptor/FITKAbstractIOAdaptor.h"

namespace Nastran
{
/**
 * @brief the abstract class of adaptor for Nastran
 *
 * @author: zhourp (zhourunping@diso.cn)
 * @date: 2024-11-14
 */
class FITKNastranBDFIOAPI FITKNastranAbstractAdaptor : public Adaptor::FITKAbstractIOAdaptor
{
    FITKCLASS(Nastran, FITKNastranAbstractAdaptor);

  public:
    /**
    * @brief Create
    * @author shenzhuowei (2931275006@qq.com)
    * @date 2025-03-05
    */
    explicit FITKNastranAbstractAdaptor() = default;

    /**
    * @brief Destory
    * @author shenzhuowei (2931275006@qq.com)
    * @date 2025-03-05
    */
    virtual ~FITKNastranAbstractAdaptor() = 0;

    /**
     * @brief Set the reader for the FITKNastranAbstractAdaptor.
     *
     * @param[in] reader Pointer to the FITKNastranBDFReader object to be set.
     * @author zhourp (zhourunping@diso.cn)
     * @date 2024-11-13
     */
    void setReader(FITKNastranBDFReader *reader);

    /**
     * @brief Set the helper for the FITKNastranAbstractAdaptor.
     *
     * @param[in] helper Pointer to the InpNastranReaderHelper object to be set.
     * @author zhourp (zhourunping@diso.cn)
     * @date 2024-11-13
     */
    void setReaderHelper(InpNastranReaderHelper *helper);

    /**
     * @brief 设置Writer
     * @param writer
     * @author shenzhuowei (2931275006@qq.com)
     * @date 2025-03-03
     */
    void setWriter(FITKNastranBDFWriter *writer);

    /**
     * @brief 设置WriterHelper
     * @param helper
     * @author shenzhuowei (2931275006@qq.com)
     * @date 2025-03-03
     */
    void setWriterHelper(InpNastranWriterHelper *helper);

  protected:
    /**
     * @brief Get the helper of the FITKNastranAbstractAdaptor.

    * @return Pointer to the InpNastranReaderHelper object.
    * @author zhourp (zhourunping@diso.cn)
    * @date 2024-11-13
    */
    InpNastranReaderHelper *getReaderHelper();

    /**
     * @brief Get the reader of the FITKNastranAbstractAdaptor.
     *
     * @return Pointer to the FITKNastranBDFReader object.
     * @author zhourp (zhourunping@diso.cn)
     * @date 2024-11-13
     */
    FITKNastranBDFReader *getReader();

    /**
     * @brief 获取WriterHelper
     * @return helper
     * @author shenzhuowei (2931275006@qq.com)
     * @date 2025-03-03
     */
    InpNastranWriterHelper *getWriterHelper();

    /**
     * @brief 获取Writer
     * @return writer
     * @author shenzhuowei (2931275006@qq.com)
     * @date 2025-03-03
     */
    FITKNastranBDFWriter *getWriter();

    /**
    * @brief 字符串转double
    * @param string 字符串数据
    * @return 转换后的字符
    * @author shenzhuowei (2931275006@qq.com)
    * @date 2025-03-05
    */
    static double String2Value(const QString& string);

    /**
    * @brief double转字符串
    * @param d double数据
    * @param prec 对double的有效字符数
    * @param width1 字符宽度
    * @param f 表示科学计数法或xxx
    * @return 转换后的字符
    * @author shenzhuowei (2931275006@qq.com)
    * @date 2025-03-05
    */
    static QString Value2String(double d, int prec = 8, int width1 = 8, char f = 'g');


  private:
    /**
     * @brief BDF文件读取器
     * @author zhourp (zhourunping@diso.cn)
     * @date 2024-03-15
     */
    FITKNastranBDFReader *_reader{};

    /**
     * @brief BDF文件读取帮助类
     * @author zhourp (zhourunping@diso.cn)
     * @date 2024-11-13
     */
    InpNastranReaderHelper *_readerHelper{};

    /**
     * @brief BDF文件写入器
     * @author shenzhuowei (2931275006@qq.com)
     * @date 2025-03-03
     */
    FITKNastranBDFWriter *_writer{};

    /**
     * @brief BDF文件写入帮助类
     * @author shenzhuowei (2931275006@qq.com)
     * @date 2025-03-03
     */
    InpNastranWriterHelper *_writerHelper{};
};
} // namespace Nastran
#endif // FITKNASTRANABSTRACTADAPTOR_H
